package com.film.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.film.domain.Film;
import com.film.service.ClassifiedFilmService;
import com.film.service.impl.ClassifiedFilmServiceImpl;

/**
 * 该控制类用来做分类查询
 * @author 2119196781
 *
 */
@WebServlet("/classifyFilm.do")
public class ClassifiedFilmController extends HttpServlet{
	private ClassifiedFilmService classifiedFilmService = new ClassifiedFilmServiceImpl();
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//正在热映
		String title = request.getParameter("title");
		//电影类型
		String types = request.getParameter("types");
		//电影产地
		String area = request.getParameter("area");
		//上映时间
		String years= request.getParameter("years");
		//排序
		String text = request.getParameter("text");
		System.out.println("____"+years);
		String flag1 = request.getParameter("flag1");
		String flag2 = request.getParameter("flag2");
		String flag3 = request.getParameter("flag3");
		String flag4 = request.getParameter("flag4");
		String flage = request.getParameter("flage");
		String pageNum = request.getParameter("pageNum");
		if("2".equals(pageNum)) {
			pageNum = "1";
		}
		List<Film> films = classifiedFilmService.selectClassifiedFilms(title, types, area, years,text);
		System.out.println(films);
		for (Film film : films) {
			System.out.println(111);
			System.out.println(film.getFilmName());
		}
		request.getSession().setAttribute("films", films);
		request.getSession().setAttribute("film", films);
		request.getSession().setAttribute("filmSize", films.size());
		response.sendRedirect("showFilm.jsp?flag1="+flag1+"&flag2="+flag2+"&flag3="+flag3+"&flage="+flage+"&flag4="+flag4+"&flag="+pageNum);
	}
}
